home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / falcon / utils / rez_fool.lzh / RTFSETU3.S < prev    next >
Text File  |  1993-09-05  |  53KB  |  2,851 lines

  1. *
  2. * Standard routine for GEM programs, by WtP (some help from Abacus GEM PR)
  3. *
  4. * Supports shared memory
  5. *
  6.  
  7. editfile        EQU        0
  8.  
  9. write_it    EQU        1
  10. info_file    EQU        2
  11. edit_mem    EQU        3
  12. want_rgb_file    EQU        4
  13. want_tv_file    EQU        5
  14. got_vga_file    EQU        6
  15. got_rgb_file    EQU        8
  16. got_tv_file    EQU        9
  17.  
  18. editmem            EQU        1
  19.  
  20. reset        EQU        1
  21. edit_file    EQU        2
  22. fool_rgb_mem    EQU        3
  23. fool_tv_mem    EQU        4
  24. got_vga_mem    EQU        5
  25. got_rgb_mem    EQU        7
  26. got_tv_mem    EQU        8
  27. info_edit    EQU       11
  28.  
  29. info_form        EQU        2
  30.  
  31. exit_info    EQU        1
  32. show_me        EQU       12
  33.  
  34. menu            EQU        3
  35.  
  36. desk_menu    EQU        3
  37. edit_menu    EQU        4
  38. misc_menu    EQU        5
  39. about        EQU        8
  40. edit_mem_menu    EQU       17
  41. edit_file_menu    EQU       18
  42. quit_menu    EQU       20
  43. write_menu    EQU       21
  44. reset_menu    EQU       22
  45.  
  46. unknown_path        EQU        4
  47.  
  48. ok_unknow_p    EQU        1
  49.  
  50. write_e            EQU        5
  51.  
  52. ok_write_e    EQU        1
  53.  
  54. faked            EQU        6
  55.  
  56. ok_faked    EQU        1
  57.  
  58. good_write        EQU        7
  59.  
  60. write_good    EQU        1
  61.  
  62. shower            EQU        8
  63.  
  64. will        EQU        1
  65.  
  66. *        opt X+                *long symbols for debugging
  67.  
  68. text:        bra    starter
  69.  
  70.         dc.b    "This program written by Pontus Sköld aka WtP of Section One ... "
  71.         dc.b    "Ryllshyttan 1, 776 98 Garpenberg, Sweden ... Send me a postcard ..."
  72.  
  73.         even
  74.  
  75. starter:    move.l    sp,d0
  76.         bne.s    got_stack
  77.  
  78.         move.l    a0,a6
  79.         bra.s    dont_read_bp_adr
  80. got_stack:
  81.         move.l    4(sp),a6
  82.  
  83. dont_read_bp_adr:
  84.         movea.l    16(a6),a4        *address to data segment
  85.         movea.l    24(a6),a5        *and to bss segment
  86.  
  87.         move.l    12(a6),d0
  88.         add.l    20(a6),d0
  89.         add.l    28(a6),d0
  90.  
  91.         add.l    #$1400,d0
  92.  
  93.         lea    stack-bss(a5),sp
  94.  
  95.         move.l    d0,-(sp)
  96.         move.l    a6,-(sp)
  97.         clr.w    -(sp)
  98.         move.w    #$4a,-(sp)
  99.         trap    #1
  100.         lea    12(sp),sp
  101.  
  102.         bsr    init_once    *setup variables one time only
  103.  
  104.         tst.w    acc_load-bss(a5)
  105.         bne    acc_mode
  106.  
  107.         moveq    #0,d0
  108.         bsr    graf_mouse
  109.  
  110.         move.l    tree_pointer-bss(a5),a0
  111.         move.l    menu*4(a0),a0
  112.  
  113.         moveq    #1,d0
  114.  
  115.         bsr    menu_bar
  116.  
  117.  
  118.  
  119. start_acc_run:    bsr    popup_window
  120.  
  121.         cmp.l    #4*editmem,rcs_screen-bss(a5)
  122.         beq    update_mem_screen
  123.  
  124.         cmp.l    #4*editfile,rcs_screen-bss(a5)
  125.         beq    update_file_screen
  126.  
  127.         bsr    send_redraw
  128. window_handling_loop:
  129.         bsr    check_rezf
  130.  
  131.         bsr    init_em_parameters
  132.  
  133.         lea    em_buffer-bss(a5),a0
  134.  
  135.         bsr    setup_em_mesag
  136.         bsr    setup_em_keyboard
  137.  
  138.         moveq    #2,d0
  139.         moveq    #1,d1
  140.         moveq    #1,d2
  141.  
  142.         bsr    setup_em_button
  143.         bsr    do_evnt_multi
  144.  
  145. return_from_evnt:
  146.         cmp.w    #1,d0
  147.         bne    not_keyboard_event
  148.  
  149.         cmp.b    #13,intout+11-bss(a5)        *return or enter
  150.         bne    not_keyboard_event
  151.  
  152.         move.l    rcs_screen-bss(a5),d0
  153.         lsr.l    #1,d0
  154.  
  155.         lea    default_list-bss(a5),a0
  156.  
  157.         move.w    0(a0,d0.w),d0
  158.         bpl    object_selected
  159.         bra    window_handling_loop
  160.  
  161. not_keyboard_event:
  162.         cmp.w    #2,d0
  163.         bne    not_mouse_button
  164.  
  165. *        bsr    init_em_parameters    *Touch exit on everything
  166.  
  167. *        moveq    #1,d0
  168. *        moveq    #1,d1
  169. *        moveq    #0,d2
  170.  
  171. *        bsr    setup_em_button
  172. *        bsr    do_evnt_multi
  173.  
  174.         move.w    intout+2-bss(a5),d6
  175.         sub.w    work_x-bss(a5),d6
  176.  
  177.         move.w    intout+4-bss(a5),d7
  178.         sub.w    work_y-bss(a5),d7
  179.  
  180.         tst.w    d6
  181.         bmi    not_mouse_button
  182.  
  183.         tst.w    d7
  184.         bmi    not_mouse_button
  185.  
  186.         cmp.w    work_w-bss(a5),d6
  187.         bpl    not_mouse_button
  188.  
  189.         cmp.w    work_h-bss(a5),d7
  190.         bpl    not_mouse_button
  191.  
  192.         move.w    intout+12-bss(a5),d0
  193.  
  194.         cmp.w    #2,d0
  195.         bne    not_toggle_screens
  196.  
  197.         tst.l    text_adr-bss(a5)
  198.         bne    toggle_screens
  199.  
  200.         cmp.l    #editfile*4,rcs_screen-bss(a5)
  201.         bne    toggle_screens
  202.  
  203.         bra    window_handling_loop
  204.  
  205. not_toggle_screens:
  206.         moveq    #0,d0            *start with object null
  207.         moveq    #7,d1            *7 levels
  208.  
  209.         move.w    intout+2-bss(a5),d2    *mouse x
  210.         move.w    intout+4-bss(a5),d3    *mouse y
  211.  
  212.         move.l    tree_pointer-bss(a5),a0
  213.         add.l    rcs_screen-bss(a5),a0
  214.         move.l    (a0),a0
  215.  
  216.         bsr    objc_find
  217.  
  218.         tst.w    d0
  219.         bmi    window_handling_loop
  220.  
  221.         move.l    tree_pointer-bss(a5),a0
  222.         add.l    rcs_screen-bss(a5),a0
  223.         move.l    (a0),a0
  224.         
  225.         move.l    d0,d2
  226.         mulu    #24,d2
  227.  
  228.         move.w    8(a0,d2.l),d1
  229.  
  230.         and.w    #%1000101,d1
  231.  
  232.         btst    #0,d1            *not selectable, nothing to
  233.         beq    window_handling_loop    *care about
  234.  
  235.         btst    #2,d1
  236.         beq    window_handling_loop
  237.  
  238.         btst    #6,d1            *if touchexit, goto object selected
  239.         bne    object_selected
  240.  
  241.         move.l    tree_pointer-bss(a5),a0
  242.         add.l    rcs_screen-bss(a5),a0
  243.         move.l    (a0),a0
  244.  
  245.         move.w    10(a0,d2.l),d5        *get old status
  246.         or.w    #1,d5            *highlighted
  247.         
  248.         move.w    work_x-bss(a5),d1
  249.         move.w    work_y-bss(a5),d2
  250.         move.w    work_w-bss(a5),d3
  251.         move.w    work_h-bss(a5),d4
  252.  
  253.         moveq    #0,d7
  254.         move.w    d0,d7
  255.  
  256.         moveq    #1,d6
  257.         bsr    objc_change
  258.  
  259.         move.l    d7,d0
  260.  
  261.         move.l    tree_pointer-bss(a5),a0
  262.         add.l    rcs_screen-bss(a5),a0
  263.         move.l    (a0),a0
  264.         
  265.         bsr    objc_offset
  266.  
  267.         move.w    intout+2-bss(a5),d1    *get x &?Γúµ?s
  268.         move.w    intout+4-bss(a5),d2    *for object...
  269.  
  270.         bsr    init_em_parameters
  271.  
  272.         move.l    d7,d0
  273.         mulu    #24,d0
  274.  
  275.         move.l    tree_pointer-bss(a5),a0
  276.         add.l    rcs_screen-bss(a5),a0
  277.         move.l    (a0),a0
  278.  
  279.         move.w    20(a0,d0.l),d3
  280.         move.w    22(a0,d0.l),d4
  281.  
  282.         moveq    #1,d0
  283.         bsr    setup_em_mouse1
  284.  
  285.         moveq    #1,d0                *max 1 click
  286.         moveq    #1,d1                *only left counts
  287.         moveq    #0,d2                *until release...
  288.  
  289.         bsr    setup_em_button
  290.  
  291.         bsr    do_evnt_multi
  292.  
  293.         move.w    d0,-(sp)        *save intout 0...
  294.  
  295.         move.l    d7,d0            *object #
  296.         mulu    #24,d0
  297.  
  298.         move.l    tree_pointer-bss(a5),a0
  299.         add.l    rcs_screen-bss(a5),a0
  300.         move.l    (a0),a0
  301.         
  302.         move.w    work_x-bss(a5),d1
  303.         move.w    work_y-bss(a5),d2
  304.         move.w    work_w-bss(a5),d3
  305.         move.w    work_h-bss(a5),d4
  306.  
  307.         move.w    10(a0,d0.l),d5        *get old status
  308.         and.w    #$fffe,d5        *not highlighted
  309.  
  310.         move.l    d7,d0
  311.  
  312.         moveq    #1,d6
  313.         bsr    objc_change
  314.  
  315.         move.w    (sp)+,d1
  316.         move.l    d7,d0
  317.  
  318.         btst    #1,d1            *if it was mouse released
  319.         bne    object_selected        *go to object_selected
  320.  
  321.         bra    window_handling_loop
  322.  
  323. not_mouse_button:
  324.         cmp.w    #$10,d0
  325.         bne    window_handling_loop
  326.  
  327.         move.w    em_buffer+4-bss(a5),d1
  328.         beq.s    not_read_more
  329.  
  330.         move.w    appl_id-bss(a5),d0
  331.  
  332.         lea    em_buffer+16-bss(a5),a0
  333.  
  334.         bsr    appl_read
  335.  
  336. not_read_more:
  337. *        move.w    appl_id-bss(a5),d0        *???
  338. *        cmp.w    em_buffer+2-bss(a5),d0
  339. *        bne    window_handling_loop
  340.  
  341.         move.w    em_buffer-bss(a5),d0
  342.  
  343.         cmp.w    #10,d0
  344.         beq    menu_options
  345.  
  346.         cmp.w    #41,d0
  347.         bne.s    not_ac_close
  348.  
  349.         move.w    em_buffer+6-bss(a5),d1
  350.         cmp.w    desk_id-bss(a5),d1
  351.         beq    delete_window_and_exit
  352.  
  353. not_ac_close:    cmp.w    #"RF",d0
  354.         beq    message_to_me
  355.  
  356.         move.w    window_handle-bss(a5),d1
  357.         cmp.w    em_buffer+6-bss(a5),d1
  358.         bne    window_handling_loop
  359.     
  360.         cmp.w    #22,d0            *wm_close
  361.         beq    close_window_and_exit
  362.  
  363.         cmp.w    #20,d0            *wm_update
  364.         beq    update_screen
  365.  
  366.         cmp.w    #21,d0            *wm_top
  367.         beq    top_my_window
  368.  
  369.         cmp.w    #10,d0
  370.         beq    menu_options
  371.  
  372.         cmp.w    #28,d0            *wm_moved
  373.         bne    window_handling_loop
  374.  
  375.         move.w    em_buffer+8-bss(a5),window_x-bss(a5)    *read new
  376.         move.w    em_buffer+10-bss(a5),window_y-bss(a5)    *pos
  377.         move.w    em_buffer+12-bss(a5),window_w-bss(a5)
  378.         move.w    em_buffer+14-bss(a5),window_h-bss(a5)
  379.  
  380.  
  381.         move.w    window_handle-bss(a5),d0
  382.         moveq    #5,d1
  383.  
  384.         move.w    window_x-bss(a5),d2
  385.         move.w    window_y-bss(a5),d3
  386.         move.w    window_w-bss(a5),d4
  387.         move.w    window_h-bss(a5),d5
  388.  
  389.         bsr    wind_set
  390.  
  391.         move.w    window_handle-bss(a5),d0    *get workarea
  392.         moveq    #4,d1                *coords
  393.  
  394.         bsr    wind_get
  395.  
  396.         move.w    intout+2-bss(a5),work_x-bss(a5)    *save, so we now it's
  397.         move.w    intout+4-bss(a5),work_y-bss(a5)    *current position
  398.         move.w    intout+6-bss(a5),work_w-bss(a5)
  399.         move.w    intout+8-bss(a5),work_h-bss(a5)
  400.  
  401.         move.l    tree_pointer-bss(a5),a0        *
  402.         add.l    rcs_screen-bss(a5),a0
  403.         move.l    (a0),a0
  404.  
  405.         move.w    work_x-bss(a5),16(a0)    *update tree coordinates
  406.         move.w    work_y-bss(a5),18(a0)
  407.  
  408.         bra    window_handling_loop
  409.  
  410. close_window_and_exit:
  411.         bsr    close_window
  412. delete_window_and_exit:
  413.         bsr    delete_window
  414.         move.w    desk_id-bss(a5),d0
  415.         cmp.w    #"er",d0
  416.         bne    acc_loop
  417. *
  418. * Go look for accs...
  419. *
  420.  
  421. * This only for program ...
  422.  
  423.         moveq    #0,d0            *erase bar
  424.  
  425.         move.l    tree_pointer-bss(a5),a0
  426.         move.l    menu*4(a0),a0
  427.  
  428.         bsr    menu_bar
  429.  
  430. something_wrong:
  431.         bsr    close_virtual
  432.         bsr    appl_exit
  433.  
  434.         moveq    #0,d0
  435.         bra.s    quit_right_now
  436.  
  437.  
  438. acc_mode:    move.w    appl_id-bss(a5),d0
  439.         lea    acc_name-data(a4),a0
  440.  
  441.         bsr    menu_register
  442.  
  443.         tst.w    d0            *if no handle, go something
  444.         bmi    something_wrong        *wrong (exit)
  445.  
  446.         move.w    d0,desk_id-bss(a5)
  447.  
  448. acc_loop:    bsr    init_em_parameters
  449.  
  450.         lea    em_buffer-bss(a5),a0
  451.         bsr    setup_em_mesag
  452.         bs